// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   CombinedXYChart.java

package org.achartengine.chart;

import android.graphics.*;
import java.util.List;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.model.XYSeries;
import org.achartengine.renderer.SimpleSeriesRenderer;
import org.achartengine.renderer.XYMultipleSeriesRenderer;

// Referenced classes of package org.achartengine.chart:
//			XYChart, TimeChart, LineChart, BarChart, 
//			BubbleChart, ScatterChart, RangeBarChart

public class CombinedXYChart extends XYChart {

	private XYChart mCharts[];
	private Class xyChartTypes[] = { TimeChart.class, LineChart.class,
			BarChart.class, BubbleChart.class, LineChart.class,
			ScatterChart.class, RangeBarChart.class };

	public CombinedXYChart(XYMultipleSeriesDataset xymultipleseriesdataset,
			XYMultipleSeriesRenderer xymultipleseriesrenderer, String as[]) {
		super(xymultipleseriesdataset, xymultipleseriesrenderer);
		int i = as.length;
		mCharts = new XYChart[i];
		for (int j = 0; j < i; j++) {
			try {
				mCharts[j] = getXYChart(as[j]);
			} catch (Exception exception) {
			}
			if (mCharts[j] == null)
				throw new IllegalArgumentException((new StringBuilder())
						.append("Unknown chart type ").append(as[j]).toString());
			XYMultipleSeriesDataset xymultipleseriesdataset1 = new XYMultipleSeriesDataset();
			xymultipleseriesdataset1.addSeries(xymultipleseriesdataset
					.getSeriesAt(j));
			XYMultipleSeriesRenderer xymultipleseriesrenderer1 = new XYMultipleSeriesRenderer();
			xymultipleseriesrenderer1.setBarSpacing(xymultipleseriesrenderer
					.getBarSpacing());
			xymultipleseriesrenderer1.setPointSize(xymultipleseriesrenderer
					.getPointSize());
			int k = xymultipleseriesdataset.getSeriesAt(j).getScaleNumber();
			if (xymultipleseriesrenderer.isMinXSet(k))
				xymultipleseriesrenderer1.setXAxisMin(xymultipleseriesrenderer
						.getXAxisMin(k));
			if (xymultipleseriesrenderer.isMaxXSet(k))
				xymultipleseriesrenderer1.setXAxisMax(xymultipleseriesrenderer
						.getXAxisMax(k));
			if (xymultipleseriesrenderer.isMinYSet(k))
				xymultipleseriesrenderer1.setYAxisMin(xymultipleseriesrenderer
						.getYAxisMin(k));
			if (xymultipleseriesrenderer.isMaxYSet(k))
				xymultipleseriesrenderer1.setYAxisMax(xymultipleseriesrenderer
						.getYAxisMax(k));
			xymultipleseriesrenderer1
					.addSeriesRenderer(xymultipleseriesrenderer
							.getSeriesRendererAt(j));
			mCharts[j].setDatasetRenderer(xymultipleseriesdataset1,
					xymultipleseriesrenderer1);
		}

	}

	private XYChart getXYChart(String s) throws IllegalAccessException,
			InstantiationException {
		XYChart xychart = null;
		int i = xyChartTypes.length;
		for (int j = 0; j < i && xychart == null; j++) {
			XYChart xychart1 = (XYChart) xyChartTypes[j].newInstance();
			if (s.equals(xychart1.getChartType()))
				xychart = xychart1;
		}

		return xychart;
	}

	public void drawSeries(Canvas canvas, Paint paint, float af[],
			SimpleSeriesRenderer simpleseriesrenderer, float f, int i) {
		mCharts[i].setScreenR(getScreenR());
		mCharts[i].setCalcRange(getCalcRange(mDataset.getSeriesAt(i)
				.getScaleNumber()), 0);
		mCharts[i].drawSeries(canvas, paint, af, simpleseriesrenderer, f, 0);
	}

	protected RectF[] clickableAreasForPoints(float af[], float f, int i) {
		return mCharts[i].clickableAreasForPoints(af, f, 0);
	}

	protected void drawSeries(
			XYSeries xyseries,
			Canvas canvas,
			Paint paint,
			List list,
			SimpleSeriesRenderer simpleseriesrenderer,
			float f,
			int i,
			org.achartengine.renderer.XYMultipleSeriesRenderer.Orientation orientation) {
		mCharts[i].setScreenR(getScreenR());
		mCharts[i].setCalcRange(getCalcRange(mDataset.getSeriesAt(i)
				.getScaleNumber()), 0);
		mCharts[i].drawSeries(xyseries, canvas, paint, list,
				simpleseriesrenderer, f, 0, orientation);
	}

	public int getLegendShapeWidth(int i) {
		return mCharts[i].getLegendShapeWidth(0);
	}

	public void drawLegendShape(Canvas canvas,
			SimpleSeriesRenderer simpleseriesrenderer, float f, float f1,
			int i, Paint paint) {
		mCharts[i].drawLegendShape(canvas, simpleseriesrenderer, f, f1, 0,
				paint);
	}

	public String getChartType() {
		return "Combined";
	}
}
